local wuchang = fk.CreateSkill {
  name = "wuchang",
  tags={Skill.Compulsory}
}
local func={
  mute = true,
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      if event == fk.AfterCardsMove then
        for _, move in ipairs(data) do
          if move.to == player.id and move.from and move.from ~= player.id and move.toArea == Card.PlayerHand and player.room:getPlayerById(move.from).kingdom ~= player.kingdom then
            if table.find(move.moveInfo, function(info) return info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip end) then
              return true
            end
          end
        end
      else
        return target == player and data.card and table.contains({"slash", "duel"}, data.card.trueName) and player.kingdom == data.to.kingdom
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(self.name)
    if event == fk.AfterCardsMove then
      for _, move in ipairs(data) do
        if move.to == player and move.from and move.from ~= player and move.toArea == Card.PlayerHand
        and table.find(move.moveInfo, function(info) return info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip end) then
          local p = move.from
          if p and p.kingdom ~= player.kingdom then
            room:notifySkillInvoked(player, self.name, "special")
            room:changeKingdom(player, p.kingdom, true)
          end
        end
      end
    else
      room:notifySkillInvoked(player, self.name, "offensive")
      data.damage = data.damage + 1
      room:changeKingdom(player, "qun", true)
    end
  end,
}
wuchang:addEffect(fk.AfterCardsMove, func)
wuchang:addEffect(fk.DamageCaused, func)

return wuchang